package com.starleague.battletech.unit;

import java.util.Map;

import com.starleague.battletech.game.AbstractBattletechGame;
import com.starleague.battletech.game.AbstractBattletechTeam;
import com.starleague.battletech.game.IMutableBattletechTeam;
import com.starleague.common.AbstractHasInfoProperties;
import com.starleague.hexagonal.IHexCoordinate;

public abstract class AbstractBattletechUnit
        extends AbstractHasInfoProperties
        implements IMutableBattletechUnit, HasMutableMovement
{
    private AbstractBattletechGame game;
    private AbstractBattletechTeam team;
    private AbstractPilot pilot;
    private AbstractWeight weight;
    private IHexCoordinate hexCoordinate;
    private int elevation;
    private BattletechUnitMovementType movementType;
    private int usedMovementPoints;

    protected AbstractBattletechUnit(AbstractBattletechGame game,
                                     AbstractBattletechTeam team,
                                     AbstractPilot pilot,
                                     AbstractWeight weight,
                                     BattletechUnitMovementType movementType)
    {
        this.game = game;
        this.team = team;
        this.pilot = pilot;
        this.weight = weight;
        this.movementType = movementType;
    }

    protected AbstractBattletechUnit()
    {
        //
    }

    public AbstractBattletechGame getGame()
    {
        return this.game;
    }

    @Override
    public AbstractBattletechTeam getTeam()
    {
        return this.team;
    }

    @Override
    public void setTeam(IMutableBattletechTeam team)
    {
        this.team = (AbstractBattletechTeam) team;
    }

    @Override
    public AbstractPilot getPilot()
    {
        return this.pilot;
    }

    @Override
    public void setPilot(IMutablePilot pilot)
    {
        this.pilot = (AbstractPilot) pilot;
    }

    @Override
    public AbstractWeight getWeight()
    {
        return this.weight;
    }

    @Override
    public IHexCoordinate getHexCoordinate()
    {
        return this.hexCoordinate;
    }

    @Override
    public void setHexCoordinate(IHexCoordinate hexCoordinate)
    {
        this.hexCoordinate = hexCoordinate;
    }

    @Override
    public int getElevation()
    {
        return this.elevation;
    }

    @Override
    public void setElevation(int elevation)
    {
        this.elevation = elevation;
    }

    @Override
    public BattletechUnitMovementType getMovementType()
    {
        return this.movementType;
    }

    @Override
    public int getUsedMovementPoints()
    {
        return this.usedMovementPoints;
    }

    @Override
    public void setUsedMovementPoints(int usedMovementPoints)
    {
        this.usedMovementPoints = usedMovementPoints;
    }

    @Override
    public void clearMovement()
    {
        this.usedMovementPoints = 0;
    }

    @Override
    public Map<String, Object> infoProperties()
    {
        Map<String, Object> infoPropertyMap = super.infoProperties();
        infoPropertyMap.put("team", this.team);
        infoPropertyMap.put("pilot", this.pilot);
        infoPropertyMap.put("hexCoordinate", this.hexCoordinate);
        infoPropertyMap.put("weight", this.weight);
        infoPropertyMap.put("elevation", this.elevation);
        infoPropertyMap.put("movementType", this.movementType);
        infoPropertyMap.put("usedMovementPoints", this.usedMovementPoints);
        return infoPropertyMap;
    }
}
